home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / BKISSSRC.ZIP / TUNNEL / TUNNEL.ASM < prev   
Encoding:
Assembly Source File  |  1994-02-13  |  8.2 KB  |  285 lines

  1. ideal
  2. locals
  3. jumps
  4. p386
  5. model huge
  6. stack 100h
  7.  
  8. TextMode = 0
  9. LoopDemo = 0
  10. AngleInc    = 3
  11. MaxZpos     = 512
  12. MinZpos     = 2
  13. WarpSpeed   = 8
  14. Step        = 15                    ;maximum number of stars per Z level
  15. MaxStars    = MaxZpos/WarpSpeed*Step
  16.  
  17. struc       Star_Struc
  18. X           dw  0       ;\
  19. Y           dw  0       ; > coordinates of star (if Z < MinZpos, star is dead)
  20. Z           dw  0       ;/
  21. CenterX     dw  0
  22. CenterY     dw  0
  23. OldDi       dw  0       ;where to erase last dot
  24. Color       db  0       ;base color (a number 0-15 is added to it)
  25. ends        Star_Struc
  26.  
  27.  
  28. segment     Code
  29.             assume cs:Code, ds:Code
  30. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  31. include     "modex.inc"
  32. include     "drawstr.inc"
  33. FadeHandler = RefreshScreen
  34. include     "palette.inc"
  35. include     "heart.inc"
  36. include     "sincos.inc"
  37. extrn       FontData:byte
  38. extrn       Palette:byte
  39. CurrentPal  db 256 dup(0,0,0)
  40. NumColors   = 5
  41. Cindex      dw 0
  42. ColorChart  db 0,32,64,96,128,160
  43. Index       dw 0
  44. XAngle      dw 0
  45. YAngle      dw 0
  46. Stars       Star_Struc MaxStars DUP (<>)
  47.                ;░░░░░░░░░░░░░░░░░░░░░;
  48. ScrollText  db 0
  49.             db ' this is my version  ',0
  50.             db 'of the old fashioned ',0
  51.             db ' tunnel of love  :)  ',0
  52.             db '                     ',0
  53.             db '                     ',0
  54.             db '                     ',0
  55.             db '     time to go!     ',0
  56.             db -1
  57. ScrollPtr   dw offset ScrollText
  58. ScrollDelay dw 0
  59. ScrollCol   dw 3
  60. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  61. proc        Start
  62.             ;set up the segments
  63.             mov ax,Code
  64.             mov ds,ax
  65.             mov es,[VGASeg]
  66.  
  67.             ;change to graphics mode
  68.             ScreenWidth = 320
  69.             ScreenHeight = 200
  70.             @SetModeX M320x200x256,320
  71.  
  72.             ;initialize the split screen
  73.             SplitHeight = 24
  74.             ScreenHeight = ScreenHeight - SplitHeight
  75.             mov bx,ScreenHeight*2       ;VGA bug when switching chaining on?
  76.             @Set_Split
  77.  
  78.             ;other stuff
  79.             mov bx,ScreenWidth/4*SplitHeight
  80.             @Set_Start_Offset
  81.             @ResetLinear
  82.  
  83.             ;write out our palette
  84.             mov si,offset CurrentPal
  85.             mov di,offset Palette
  86.             call fade_to
  87.  
  88.             ;clear out the bottom
  89.             xor di,di
  90.             mov cx,SplitHeight*ScreenWidth
  91.             mov al,198
  92.             rep stosb
  93.  
  94. @@MainLoop: call RefreshScreen
  95.             jc @@AllDone
  96.  
  97.             ;get stdio.  If something's been pressed, quit
  98.             mov ah,6
  99.             mov dl,0FFh
  100.             int 21h
  101.             jz @@MainLoop
  102.  
  103. @@AllDone:  call fade_out
  104.  
  105.             ;return to text mode and quit to DOS
  106.             if TextMode ne 0
  107.                 mov ax,0003h
  108.                 int 10h
  109.             endif
  110.             mov ax,4C00h
  111.             int 21h
  112. endp        Start
  113. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  114. proc        RefreshScreen
  115.             ;put some text at the bottom
  116.             cmp [ScrollDelay],0
  117.             jnz @@NoText
  118. @@DecodeIt: mov si,[ScrollPtr]
  119.             cmp [byte si],0
  120.             jz @@EndOfLine
  121.             cmp [byte si],-1
  122.             jz @@EndOfText
  123.             push [VGASeg] 0
  124.             push 2 [ScrollCol]
  125.             push (seg ScrollText) [ScrollPtr]
  126.             push (seg FontData) (offset FontData)
  127.             call _Draw_Letter
  128.             add sp,16
  129.             add [ScrollCol],ax
  130.             inc [ScrollPtr]
  131.             mov [ScrollDelay],2
  132.             jmp @@NoText
  133. @@EndOfLine:inc [ScrollPtr]
  134.             mov [ScrollDelay],80
  135.             mov [ScrollCol],3
  136.             jmp @@NoText
  137. @@EndOfText:if LoopDemo ne 0
  138.                 mov [ScrollPtr],offset ScrollText
  139.                 mov [ScrollDelay],1     ;cause it will be DEC'd two lines below
  140.                 mov [ScrollCol],3
  141.             else
  142.                 stc
  143.                 ret
  144.             endif
  145. @@NoText:   dec [ScrollDelay]
  146.  
  147.             ;make some more stars
  148.             call MakeStar
  149.             add [XAngle],AngleInc*2
  150.             and [XAngle],1023
  151.             add [YAngle],AngleInc
  152.             and [YAngle],1023
  153.  
  154.             ;wait for a full vertical retrace (for timing)
  155.             @FullVertWait
  156.  
  157.             ;draw the stars
  158.             call DisplayStars
  159.  
  160.             clc
  161.             ret
  162. endp        RefreshScreen
  163. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  164. ;finds 1st available slot for a star and puts it there
  165. proc        MakeStar
  166.             mov bp,Step
  167.             ;search for first available slot
  168.             mov si,offset Stars
  169. @@TryAgain: cmp [si+Star_Struc.Z],MinZpos
  170.             jg @@NextStar
  171.  
  172. @@GotOne:   ;generate a color for the star
  173.             mov di,[Cindex]
  174.             mov al,[ColorChart+di]
  175.             mov [si+Star_Struc.Color],al
  176.  
  177.             ;get the next default point list pointer
  178.             mov di,[Index]
  179.             imul di,size Point_Type
  180.             add di,offset DefaultPoints
  181.  
  182.             ;generate an X coordinate for the star
  183.             mov ax,[di+Point_Type.X]
  184.             sal ax,5
  185.             mov [si+Star_Struc.X],ax
  186.  
  187.             ;generate a Y coordinate for the star
  188.             mov ax,[di+Point_Type.Y]
  189.             sal ax,5
  190.             mov [si+Star_Struc.Y],ax
  191.  
  192.             ;generate a Z coordinate for the star
  193.             mov [si+Star_Struc.Z],MaxZpos
  194.  
  195.             ;generate a Center X for the star
  196.             mov di,[XAngle]
  197.             shl di,1
  198.             mov ax,(ScreenWidth/2)-80
  199.             imul [Cosine+di]
  200.             shl edx,16
  201.             mov dx,ax
  202.             sar edx,8
  203.             add edx,ScreenWidth/2
  204.             mov [si+Star_Struc.CenterX],dx
  205.  
  206.             ;generate a Center Y for the star
  207.             mov di,[YAngle]
  208.             shl di,1
  209.             mov ax,(ScreenHeight/2)-50
  210.             imul [Sine+di]
  211.             shl edx,16
  212.             mov dx,ax
  213.             sar edx,8
  214.             add edx,ScreenHeight/2
  215.             mov [si+Star_Struc.CenterY],dx
  216.  
  217.             ;update all of these pointers
  218.             inc [Index]
  219.             cmp [Index],NumDefaultPoints
  220.             jb @@IndexOK
  221.             mov [Index],0
  222. @@IndexOK:  inc [Cindex]
  223.             cmp [Cindex],NumColors
  224.             jb @@ColorOK
  225.             mov [Cindex],0
  226. @@ColorOK:  dec bp
  227.             jz @@Quit
  228.  
  229. @@NextStar: add si,size Star_Struc
  230.             cmp si,offset Stars+MaxStars*size Star_Struc
  231.             jb @@TryAgain
  232. @@Quit:     ret
  233. endp        MakeStar
  234. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  235. ;update the display
  236. proc        DisplayStars
  237.             mov si,offset Stars
  238. @@Search:   cmp [si+Star_Struc.Z],MinZpos
  239.             jle @@NextStar
  240.  
  241.             ;erase the old star
  242.             mov di,[si+Star_Struc.OldDi]
  243.             mov [byte es:di],0
  244.  
  245.             ;compute screen Y coordinate
  246.             mov ax,[si+Star_Struc.Y]
  247.             cwd
  248.             idiv [si+Star_Struc.Z]
  249.             add ax,[si+Star_Struc.CenterY]
  250.             cmp ax,ScreenHeight
  251.             jae @@KillStar
  252.             imul di,ax,ScreenWidth          ;DI = row * ScreenWidth
  253. add di,ScreenWidth*SplitHeight
  254.  
  255.             ;compute screen X coordinate
  256.             mov ax,[si+Star_Struc.X]
  257.             cwd
  258.             idiv [si+Star_Struc.Z]
  259.             add ax,[si+Star_Struc.CenterX]
  260.             cmp ax,ScreenWidth
  261.             jae @@KillStar
  262.             add di,ax                       ;DI = row * ScreenWidth + col
  263.             mov [si+Star_Struc.OldDi],di    ;save it
  264.  
  265.             ;calculate the color
  266.             mov ax,[si+Star_Struc.Z]
  267.             shr ax,4
  268.             add al,[si+Star_Struc.Color]
  269.             mov [byte es:di],al
  270.  
  271.             ;move the star closer
  272.             mov ax,WarpSpeed
  273.             sub [si+Star_Struc.Z],ax
  274.             jmp @@NextStar
  275.  
  276. @@KillStar: mov [si+Star_Struc.Z],0
  277. @@NextStar: add si,size Star_Struc
  278.             cmp si,offset Stars+MaxStars*size Star_Struc
  279.             jb @@Search
  280.             ret
  281. endp        DisplayStars
  282. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  283. ends        Code
  284.             end Start
  285.